/**
 * Created by Xwen on 2016/11/1.
 */
function get_height(){
    var a=document.getElementById('a');
    var h=a.offsetHeight;
    a.style.lineHeight=h+"px";
}

window.onload=function(){
    get_height();

}
window.onresize=function(){
    get_height();
}

function create_info_block(width,height,detail_block_id,title){
    // function create_info_block(width,height,detail_block_id,title,isRemoveable){
    if(document.getElementById("no")==null){
        var main_box=document.createElement("div");
        var title_block=document.createElement("div");
        var detail_block=document.createElement("div");
        var title_content=document.createElement("span");
        var close_button=document.createElement("span");

        main_box.id="main_box";
        title_block.id="title_block";
        detail_block.id="detail_block";
        title_content.id="title_content";
        close_button.id="close_button";
        close_button.title="点击关闭";

        title_content.innerHTML=title;
        close_button.innerHTML="<img src='./image/close_button.png'/>";
        title_block.appendChild(title_content);
        title_block.appendChild(close_button);

        if(detail_block_id != null){
            detail_block_id.style.display="block";
            detail_block.appendChild(detail_block_id);
        }

        main_box.appendChild(title_block);
        main_box.appendChild(detail_block);

        var width_distance=(document.body.clientWidth-width)/2;
        var height_distance=(document.body.clientHeight-height)/2;
        var detail_block_height=height-70;
        var main_box_css="position:absolute;z-index:9999;border-radius:10px;opacity:0.9;background-color:#FFFFFF;top:"+height_distance+"px;left:"+width_distance+"px;width:"+width+"px;height:"+height+"px;";
        var detail_block_css="width:96%;margin-top:15px;padding:0px 2%;height:"+detail_block_height+"px;";

        main_box.style.cssText=main_box_css;
        title_block.style.cssText="width:98%;height:70px;padding:0px 1%;";
        detail_block.style.cssText=detail_block_css;
        title_content.style.cssText="width:70%;height:100%;font-family:微软雅黑;line-height:70px;font-size:36px;float:left;";
        close_button.style.cssText="width:50px;height:50px;padding-top:10px;float:right;";

        close_button.onclick=function(){
            main_box.parentNode.removeChild(main_box);
        }



        return main_box;
    }

}
function show_info_block(){
    var main=document.getElementById('main');
    var a_block1=document.getElementById('a_block1');
    var a_block2=document.getElementById('a_block2');
    var a_block3=document.getElementById('a_block3');
    var a_block4=document.getElementById('a_block4');
    var a1=document.getElementById('a1');
    var a2=document.getElementById('a2');
    var a3=document.getElementById('a3');
    var a4=document.getElementById('a4');

    a_block1.onclick=function(){
        main.appendChild(create_info_block(750,320,a1,'网络教学综合平台-校内版'));
    }
    a_block2.onclick=function(){
        main.appendChild(create_info_block(750,320,a2,'网络自主学习平台-高校版'));
    }
    a_block3.onclick=function(){
        main.appendChild(create_info_block(750,320,a3,'计算机应用基础 SPOC 课程'));
    }
    a_block4.onclick=function(){
        main.appendChild(create_info_block(750,320,a4,'计算机俱乐部'));
    }
}
